interface IProduct {
   name: string;
   price: number;
}

interface IPerson {
   name: string;
   age?: number;
   eat: (food?: string) => void;
   sleep: (hours: number) => void;
   work: (hours: number) => IProduct;
}

/* 类实现接口，就必须实现接口规定的所有必选属性或方法 */
class Person implements IPerson {
   // public name: string;
   // public age?: number;
   constructor(public name: string, public age: number) {}

   eat(food?: string): void {
      console.log(this.name, "eat", food ? food : "饭");
   }

   sleep(hours: number) {
      console.log(this.name, "sleep", hours, "小时");
   }

   work(hours: number) {
      return {
         name: "",
         price: 123,
      };
   }

   add(a: number, b: number) {
      return a + b;
   }
}

// new IPerson()
const zsf = new Person("张三疯", 60);
